<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>payInsert - Swim System</title>
		<link rel="shortcut icon" href="favicon.ico">
		<link href="/swimpool-ssm/back/resources/css/bootstrap.min.css?v=3.3.5"
			rel="stylesheet">
		<link
			href="/swimpool-ssm/back/resources/css/font-awesome.min.css?v=4.4.0"
			rel="stylesheet">
		<link href="/swimpool-ssm/back/resources/css/animate.min.css"
			rel="stylesheet">
		<link href="/swimpool-ssm/back/resources/css/style.min.css?v=4.0.0"
			rel="stylesheet">
		
		<script src="/swimpool-ssm/back/resources/js/jquery.min.js?v=2.1.4"></script>
		<script src="/swimpool-ssm/back/resources/js/bootstrap.min.js?v=3.3.5"></script>
		<script src="/swimpool-ssm/back/resources/js/content.min.js?v=1.0.0"></script>
		<script
			src="/swimpool-ssm/back/resources/js/plugins/validate/jquery.validate.min.js"></script>
		<script
			src="/swimpool-ssm/back/resources/js/plugins/validate/messages_zh.min.js"></script>
		<script
			src="/swimpool-ssm/back/resources/js/demo/form-validate-demo.min.js"></script>
		<script type="text/javascript" src="/swimpool-ssm/js/My97DatePicker/WdatePicker.js"></script>
		<script src="/swimpool-ssm/js/util.js"></script>
	</head>

<body class="gray-bg">
	<div class="wrapper wrapper-content animated">
		<div class="row">
			<div class="col-sm-11">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>Pay Insert</h5>
						<div class="ibox-tools">
							<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
							</a> <a class="dropdown-toggle" data-toggle="dropdown"
								href="form_basic.html#"> <i class="fa fa-wrench"></i>
							</a>
						</div>
					</div>
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="form">
							<!-- input hidden -->
							<input type="hidden" name="goodsId" id="goodsId">
							<input type="hidden" name="classId" id="classId">
							<input type="hidden" name="usersId" id="usersId">
							
							<div class="form-group">
								<label class="col-sm-3 control-label">payType：</label>
								<div class="col-sm-8">
									<select name="payType" id="payType" class="form-control" onchange="computePrice()">
										<option value="0">class</option>
										<option value="1">week</option>
										<option value="2">year</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">beginTime：</label>
								<div class="col-sm-8">
									<input id="beginTime" type="text" class="form-control" name="beginTimeStr" value=""
										onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
										required="" aria-required="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">endTime：</label>
								<div class="col-sm-8">
									<input id="endTime" type="text" class="form-control" name="endTimeStr" value=""
										onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
										required="" aria-required="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">totalClassNum：</label>
								<div class="col-sm-8">
									<input id="totalClassNum" type="number" class="form-control" name="totalClassNum" value="0"
										required="" aria-required="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">price：</label>
								<div class="col-sm-8">
									<input id="price" type="number" class="form-control" name="price" readonly="readonly" value="0"
										required="" aria-required="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">totalPrice：</label>
								<div class="col-sm-8">
									<input id="totalPrice" type="number" class="form-control" name="totalPrice" readonly="readonly" value="0"
										required="" aria-required="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">discount：</label>
								<div class="col-sm-8">
									<input id="discount" type="number" class="form-control" name="discount" readonly="readonly" value="0"
										required="" aria-required="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">dealPrice：</label>
								<div class="col-sm-8">
									<input id="dealPrice" type="number" class="form-control" name="dealPrice" readonly="readonly" value="0"
										required="" aria-required="true">
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-4 col-sm-offset-3">
									<button class="btn btn-primary" type="button"
										onclick="formSubmit()">submit</button>
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-4 col-sm-offset-3">
									<span id="info"></span>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
<script type="text/javascript">
	/* 获取id */
	var goodsId = urlParam("goodsId") ; 
	$("#goodsId").val(goodsId)
	/* 获取id */
	var classId = urlParam("classId") ; 
	$("#classId").val(classId)
	/**
		computePrice
	*/
	function computePrice()
	{
		/* 获取用户Id;一定是用户 */
		var obj = getData("users");
		if(obj != '' && obj != undefined)
		{
			var jsonObj = JSON.parse(obj);
			$("#usersId").val(jsonObj.id);
		}else
		{
			$("#usersId").val("0");
		}
		
		var param = $("#form").serialize();
		$.post(
			rootPath + "/class/payCompute.mvc",
			param,
			function(data)
			{
				console.info("======" + data)
				var obj = data ; 
				$("#totalClassNum").val(obj.totalClassNum);
				$("#price").val(obj.price);
				$("#totalPrice").val(obj.totalPrice);
				$("#discount").val(obj.discount);
				$("#dealPrice").val(obj.dealPrice);
				
				$("#beginTime").val(obj.beginTime);
				$("#endTime").val(obj.endTime);
			},
			"json"
		);
		return false ; 
	}
	/* init price */
	computePrice();
	
	/**
		提交
	*/
	function formSubmit()
	{
		var param = $("#form").serialize();
		
		$.post(
			rootPath + "/class/payInsert.mvc",
			param,
			function(data)
			{
				$("#info").html(data.info);
			},
			"json"
		);
		return false ; 
	}
</script>